package com.example.administrator.audioandvideo

class Complex(var real: Double, var imaginary: Double) {
    operator fun plus(other: Complex): Complex {
        return Complex(real + other.real, imaginary + other.imaginary)
    }

    override fun toString(): String {
        return "$real+${imaginary}i"
    }

}

fun main(args: Array<String>) {
//    val c1 = Complex(3.0, 4.0)
//    val c2 = Complex(4.0, 4.3)
//    println(c1 + c2)
//
//    for (indexedValue in args.withIndex()) {
//        println("${indexedValue.index} ${indexedValue.value}")
//    }

    val list = MyIntList()
    list.add(1)
    list.add(2)
    list.add(3)

    for (i in list){
        println(i)
    }
}

class MyIterator(val iterator: Iterator<Int>) {
    operator fun next(): Int {
        return iterator.next()
    }

    operator fun hasNext(): Boolean {
        return iterator.hasNext()
    }
}

class MyIntList {
    private val list = ArrayList<Int>()

    fun add(int: Int) {
        list.add(int)
    }

    fun remove(int: Int) {
        list.remove(int)
    }

    operator fun iterator():MyIterator{
        return MyIterator(list.iterator())
    }

    fun test(age:Int,name:String,sax:String){

    }


}